<template>
	<div id="courseAndTeach" class="page courseInfo base-content">
		<ul class="base-item-tab">
			<li>
				<router-link to="/BaseSetting/teachTime">教学时间</router-link>
			</li>
			<li>
				<router-link to="/BaseSetting/courseInfo">课程信息</router-link>
			</li>
			<li>
				<router-link to="/BaseSetting/teacher">教师信息</router-link>

			</li>
			<li v-if="old.classType==2">
				<router-link to="/BaseSetting/classRoomInfo">教室信息</router-link>
			</li>
			<li>
				<router-link to="/BaseSetting/courseAndTeach" class="active">教师及课时分配</router-link>
			</li>
		</ul>
		<div class="row" v-loading="dom.tableLoading">
			<div class="col-xs-12">
                  <el-table class="tableCount"
                    :data="tableData"
                    border
                    max-height="500">
                    <el-table-column
                    fixed
                    prop="greadName"
                    label="年级"
                    align="center"
                    width="110">
                    </el-table-column>
                    <el-table-column
                    fixed
                    prop="className"
                    label="班级"
                    align="center"
                    width="110">
                    </el-table-column>
                    
                    <el-table-column
                    prop="type"
                    label="班级类型/备注"
                    align="center"
                    width="120">
                    </el-table-column>

                    <el-table-column
                    label="班主任"
                    prop="preceptor"
                    align="center"
                    width="80">
                    </el-table-column>

                    <el-table-column
                    label="语文"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.chinese"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.chineseNum == 0 ? '' : scope.row.chineseNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="数学"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.math"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.mathNum == 0 ? '' : scope.row.mathNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="外语"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.english"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.englishNum == 0 ? '' : scope.row.englishNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="物理"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.physics"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.physicsNum == 0 ? '' : scope.row.physicsNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="化学"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.biology"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.biologyNum == 0 ? '' : scope.row.biologyNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="生物"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.politics"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.politicsNum == 0 ? '' : scope.row.politicsNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="政治"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.geography"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.geographyNum == 0 ? '' : scope.row.geographyNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="地理"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.science"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.scienceNum == 0 ? '' : scope.row.scienceNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="历史"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.history"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.historyNum == 0 ? '' : scope.row.historyNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="通技"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.technic"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.technicNum == 0 ? '' : scope.row.technicNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="美术"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.art"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.artNum == 0 ? '' : scope.row.artNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="体育"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.pe"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.peNum == 0 ? '' : scope.row.peNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="艺术"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.fineArt"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.fineArtNum == 0 ? '' : scope.row.fineArtNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="信息"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.computer"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.computerNum == 0 ? '' : scope.row.computerNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <el-table-column
                    label="班会"
                    align="center"
                    width="120">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.meeting"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.meetingNum == 0 ? '' : scope.row.meetingNum"></span>
                        </div>
                    </template>
                    </el-table-column>

                    <!-- <el-table-column
                    label="课时总计"
                    align="center"
                    width="200">
                    <template slot-scope="scope">
                        <div>
                            <span class="tableSpan  tableName" v-text="scope.row.TimeAll"></span>
                            <span class="tableSpan  tableNum" v-text="scope.row.TimeAllNum"></span>
                        </div>
                    </template>
                    </el-table-column> -->


                    <el-table-column
                    fixed="right"
                    label="课时总计"
                    align="center"
                    width="80">
                    <template slot-scope="scope">
                        <div>
                            {{scope.row.timeAll}}节/周
                        </div>
                    </template>
                    </el-table-column>
                    <!-- <el-table-column
                    fixed="right"
                    label="操作"
                    width="100">
                    <template slot-scope="scope">
                        <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
                        <el-button type="text" size="small">编辑</el-button>
                    </template>
                    </el-table-column> -->
                </el-table>


			</div>
		</div>
	</div>
</template>

<script>
	import utils from '@/assets/js/urlConfig.js'

	export default {
		props:['tnId'],
		data() {
			return {
                a:1,
                dom:{
                    tableLoading: false,
                },
                old:{
                    schoolId:'',
                    urla: '',
                    taskId: '',
                    classType: 0,
                },
                tableData: [
                    {
                        greadName:'高二',
                        className:'1班',
                        type:'政史技',
                        preceptor:'蔡俊胜',
                        chinese   :'张莉萍',chineseNum   :5,
                        math      :'蔡俊胜',mathNum      :5,
                        english   :'朱金仙',englishNum   :5,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum        :0,
                        politics  : '蒋良国',politicsNum :3,
                        geography :'陶美丽',geographyNum :3,
                        science   :'',scienceNum        :0,
                        history   :'郑超',historyNum     :3,
                        technic   :'罗永伟',technicNum   :3,
                        art       :'',artNum             :0,
                        pe        :'沈佳',peNum          :2,
                        fineArt   :'包启波',fineArtNum   :2,
                        computer  :'金立泉',computerNum  :3,
                        meeting   :'蔡俊胜',meetingNum   :1
                    },
                    {
                        greadName:'高二',
                        className:'2班',
                        type:'史地技',
                        preceptor:'蒋良国',
                        chinese   :'张莉萍',chineseNum   :5,
                        math      :'蔡俊胜',mathNum      :5,
                        english   :'朱金仙',englishNum   :5,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum        :0,
                        politics  : '蒋良国',politicsNum :3,
                        geography :'周佳佳',geographyNum :3,
                        science   :'胡安一',scienceNum   :3,
                        history   :'周雪飞',historyNum   :3,
                        technic   :'罗永伟',technicNum   :3,
                        art       :'',artNum             :0,
                        pe        :'沈佳',peNum          :2,
                        fineArt   :'包启波',fineArtNum   :1,
                        computer  :'金立泉',computerNum  :3,
                        meeting   :'蒋良国',meetingNum   :1
                    },
                    {
                        greadName:'高二',
                        className:'3班',
                        type:'政史地',
                        preceptor:'胡安一',
                        chinese   :'吕加正',chineseNum   :5,
                        math      :'马小友',mathNum      :5,
                        english   :'欧阳',englishNum     :5,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum        :0,
                        politics  : '蒋良国',politicsNum :3,
                        geography :'周佳佳',geographyNum :3,
                        science   :'胡安一',scienceNum   :3,
                        history   :'周雪飞',historyNum   :3,
                        technic   :'罗永伟',technicNum   :3,
                        art       :'',artNum             :0,
                        pe        :'沈佳',peNum          :2,
                        fineArt   :'包启波',fineArtNum   :1,
                        computer  :'冯中云',computerNum  :3,
                        meeting   :'胡安一',meetingNum   :1
                    },
                    {
                        greadName:'高二',
                        className:'4班',
                        type:'政地+史、化',
                        preceptor:'郑超',
                        chinese   :'吕加正',chineseNum   :5,
                        math      :'马小友',mathNum      :5,
                        english   :'周金飞',englishNum   :5,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum        :0,
                        politics  : '鲍英英',politicsNum :3,
                        geography :'陶美丽',geographyNum :3,
                        science   :'胡安一',scienceNum   :3,
                        history   :'',historyNum         :0,
                        technic   :'朱计兵',technicNum   :3,
                        art       :'',artNum             :0,
                        pe        :'沈佳',peNum          :2,
                        fineArt   :'包启波',fineArtNum   :1,
                        computer  :'冯中云',computerNum  :3,
                        meeting   :'郑超',meetingNum     :1
                    },
                    {
                        greadName:'高二',
                        className:'5班',
                        type:'技化生',
                        preceptor:'夏秀秀',
                        chinese   :'夏秀秀',chineseNum   :5,
                        math      :'李茂兵',mathNum      :5,
                        english   :'周金飞',englishNum   :5,
                        physics   :'',physicsNum         :0,
                        biology   : '叶林森',biologyNum   :3,
                        politics  : '鲍英英',politicsNum :3,
                        geography :'陶美丽',geographyNum :3,
                        science   :'',scienceNum         :0,
                        history   :'',historyNum         :0,
                        technic   :'钱存',technicNum     :3,
                        art       :'',artNum             :0,
                        pe        :'赵万勇',peNum         :2,
                        fineArt   :'包启波',fineArtNum   :1,
                        computer  :'何礼聪',computerNum  :3,
                        meeting   :'夏秀秀',meetingNum     :1
                    },
                    {
                        greadName:'高二',
                        className:'6班',
                        type:'政史技',
                        preceptor:'王玲琴',
                        chinese   :'夏秀秀',chineseNum   :5,
                        math      :'张海峰',mathNum      :5,
                        english   :'王玲琴',englishNum   :5,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum   :0,
                        politics  : '蒋良国',politicsNum :3,
                        geography :'李玲玲',geographyNum :3,
                        science   :'',scienceNum         :0,
                        history   :'周雪飞',historyNum         :3,
                        technic   :'钱存',technicNum     :3,
                        art       :'陈 汉',artNum             :6,
                        pe        :'赵万勇',peNum         :1,
                        fineArt   :'',fineArtNum   :0,
                        computer  :'何礼聪',computerNum  :3,
                        meeting   :'王玲琴',meetingNum     :1
                    },
                    {
                        greadName:'高二',
                        className:'7班',
                        type:'史地技',
                        preceptor:'包彦强',
                        chinese   :'陶丽娇',chineseNum   :5,
                        math      :'李茂兵',mathNum      :5,
                        english   :'王玲琴',englishNum   :5,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum   :0,
                        politics  : '鲍英英',politicsNum :3,
                        geography :'李玲玲',geographyNum :3,
                        science   :'朱瑞卫',scienceNum         :3,
                        history   :'郑超',historyNum         :3,
                        technic   :'马仙鹤',technicNum     :3,
                        art       :'陈 汉',artNum             :6,
                        pe        :'赵万勇',peNum         :1,
                        fineArt   :'',fineArtNum   :0,
                        computer  :'何礼聪',computerNum  :3,
                        meeting   :'包彦强',meetingNum     :1
                    },
                    {
                        greadName:'高二',
                        className:'8班',
                        type:'政地+史、化',
                        preceptor:'周海英',
                        chinese   :'陶丽娇',chineseNum   :5,
                        math      :'张海峰',mathNum      :5,
                        english   :'周海英',englishNum   :5,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum   :0,
                        politics  : '王赛春',politicsNum :3,
                        geography :'周佳佳',geographyNum :3,
                        science   :'朱瑞卫',scienceNum         :3,
                        history   :'',historyNum         :0,
                        technic   :'马仙鹤',technicNum     :3,
                        art       :'许燕敏',artNum             :6,
                        pe        :'赵万勇',peNum         :1,
                        fineArt   :'',fineArtNum   :0,
                        computer  :'金立泉',computerNum  :3,
                        meeting   :'周海英',meetingNum     :1
                    },
                    {
                        greadName:'高二',
                        className:'9班',
                        type:'政史地',
                        preceptor:'沈剑',
                        chinese   :'沈剑',chineseNum   :5,
                        math      :'李秀英',mathNum      :5,
                        english   :'周海英',englishNum   :5,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum   :0,
                        politics  : '王赛春',politicsNum :3,
                        geography :'杨荷芳',geographyNum :3,
                        science   :'朱瑞卫',scienceNum         :3,
                        history   :'周雪飞',historyNum         :3,
                        technic   :'朱计兵',technicNum     :3,
                        art       :'许燕敏',artNum             :6,
                        pe        :'赵万勇',peNum         :1,
                        fineArt   :'',fineArtNum   :0,
                        computer  :'金立泉',computerNum  :3,
                        meeting   :'沈剑',meetingNum     :1
                    },
                    {
                        greadName:'高二',
                        className:'化学1班（选）',
                        type:'',
                        preceptor:'',
                        chinese   :'',chineseNum   :0,
                        math      :'',mathNum      :0,
                        english   :'',englishNum   :0,
                        physics   :'',physicsNum         :0,
                        biology   : '叶林森',biologyNum   :3,
                        politics  : '',politicsNum :0,
                        geography :'',geographyNum :0,
                        science   :'',scienceNum         :0,
                        history   :'',historyNum         :0,
                        technic   :'',technicNum     :0,
                        art       :'',artNum             :0,
                        pe        :'',peNum         :0,
                        fineArt   :'',fineArtNum   :0,
                        computer  :'',computerNum  :0,
                        meeting   :'',meetingNum     :0
                    },
                    {
                        greadName:'高二',
                        className:'历史1班（选）',
                        type:'',
                        preceptor:'',
                        chinese   :'',chineseNum   :0,
                        math      :'',mathNum      :0,
                        english   :'',englishNum   :0,
                        physics   :'',physicsNum         :0,
                        biology   : '',biologyNum   :0,
                        politics  : '',politicsNum :0,
                        geography :'',geographyNum :0,
                        science   :'',scienceNum         :0,
                        history   :'郑超',historyNum         :3,
                        technic   :'',technicNum     :0,
                        art       :'',artNum             :0,
                        pe        :'',peNum         :0,
                        fineArt   :'',fineArtNum   :0,
                        computer  :'',computerNum  :0,
                        meeting   :'',meetingNum     :0
                    },
                ],
                    // 获取row的key值
                    getRowKeys(row) {
                        return row.id;
                    },
			}
		},
		mounted() {
            this.getTeachTime();
            this.compTime();
		},
		methods: {
			// 获取课程信息 & 基础信息
			getTeachTime() {
				this.old.urla = utils.UrlConfig.saveOrUpdateCourseTime;
				this.old.taskId = sessionStorage.getItem('taskId');
				this.old.classType = sessionStorage.getItem('classType');
				
				this.$http.get(utils.UrlConfig.getTokenValue)
				.then(res => {
					this.schoolId = res.data.bizData.tnId;
				})
            },
            compTime() {
                for(var i = 0 ; i < this.tableData.length ; i++){
                    var sing = 0;
                    var doub = 0;
                    var li = this.tableData;
                    for(var k in li[i]){
                        if(k.indexOf('Num') != -1){
                            li[i][k] = li[i][k] + '';
                            var index = li[i][k].indexOf('+') == -1 ? 1 : li[i][k].indexOf('+');
                            sing += li[i][k].slice(0,index) - 0;
                            doub += li[i][k].slice(index+1) - 0;
                        }
                    }
                    li[i]['timeAll'] = sing + doub;
                }
            },
            // 表格
            handleClick(row) {
                console.log(row);
            },
            aaa(row, column, cell, event){
                // row.name='aaa'
                console.log(row)
                console.log(column)
            },
            indexMethod(index){
                return index;
            }
		}
	}
</script>

<style>
    #courseAndTeach .cell{
        padding:0;
    }
</style>

<style scoped>
	.title-2{
		padding-top:0px;
	}

	.courseInfo .base-item-tab {
		padding-bottom: 7px;
	}
	
	.courseInfo .base-item-tab li+li+li a {
		border-right: 1px solid #D8D8D8 !important;
	}
	
	.courseInfo .base-item-tab li:last-child a {
		border-right: 0 !important;
    }
    
    .tableCount{
        margin-top:20px;
    }

    .cell>div{
        position: absolute;
        top:0;
        left:0;
        width: 100%;
        height: 100%;
        text-align: center;
        line-height: 40px;
    }

    thead,thead,tr,th,td,.cell{
        text-align:center;
    }

    .cell{
        padding-left:0 !important;
        padding-right:0 !important;
    }
    
    .tableSpan{
        display:inline-block;
        float:left;
        height: 100%;
        text-align:center;
        line-height:40px;
    }

    .tableSpan:nth-of-type(1){
        width: 70%;
    }

    .tableSpan:nth-of-type(2){
        width: 30%;
    }

    .tableName{
        border-right:1px solid #dfe6ec;
    }
</style>